/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * LoginPage.java
 *
 * Created on Oct 24, 2011, 7:41:51 PM
 */
package VIMS;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;

/**
 *
 * @author shyan
 */
public class LoginPage extends javax.swing.JFrame {

    /** Creates new form LoginPage */
    public LoginPage() {
 
        
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int width  = screenSize.width;
        int height = screenSize.height;
        initComponents();
        setSize(width-4,height-38);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel2 = new javax.swing.JPanel();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        ExitButton = new javax.swing.JButton();
        Logo = new javax.swing.JLabel();
        PwLabel = new javax.swing.JLabel();
        UserIDLabel = new javax.swing.JLabel();
        InputID = new javax.swing.JTextField();
        InputPW = new javax.swing.JPasswordField();
        jLabel4 = new javax.swing.JLabel();
        LoginButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new java.awt.GridBagLayout());

        jPanel2.setPreferredSize(new java.awt.Dimension(960, 720));
        jPanel2.setLayout(new java.awt.GridBagLayout());

        jLayeredPane1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        ExitButton.setText("Exit");
        ExitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExitButtonActionPerformed(evt);
            }
        });
        ExitButton.setBounds(540, 490, 70, 23);
        jLayeredPane1.add(ExitButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Logo.setFont(new java.awt.Font("Times New Roman", 3, 48));
        Logo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Logo.setText("Logo");
        Logo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        Logo.setBounds(290, 90, 380, 240);
        jLayeredPane1.add(Logo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        PwLabel.setText("Password :");
        PwLabel.setBounds(380, 440, 70, 30);
        jLayeredPane1.add(PwLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        UserIDLabel.setText("User ID    :");
        UserIDLabel.setBounds(380, 400, 70, 30);
        jLayeredPane1.add(UserIDLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);
        InputID.setBounds(460, 400, 120, 30);
        jLayeredPane1.add(InputID, javax.swing.JLayeredPane.DEFAULT_LAYER);
        InputPW.setBounds(460, 440, 120, 30);
        jLayeredPane1.add(InputPW, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, null, new java.awt.Color(204, 204, 255), null, null));
        jLabel4.setBounds(350, 370, 260, 120);
        jLayeredPane1.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LoginButton.setText("Login");
        LoginButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoginButtonActionPerformed(evt);
            }
        });
        LoginButton.setBounds(470, 490, 70, 23);
        jLayeredPane1.add(LoginButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.ipadx = 959;
        gridBagConstraints.ipady = 719;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        jPanel2.add(jLayeredPane1, gridBagConstraints);

        getContentPane().add(jPanel2, new java.awt.GridBagConstraints());

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ExitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitButtonActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_ExitButtonActionPerformed

    private void LoginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginButtonActionPerformed
        
        Login LoginOb = new Login(InputID.getText().trim(),InputPW.getText().trim());      
        System.out.println(LoginOb.check());
        if(LoginOb.check()==true)
        {
            this.setVisible(false);
            new MainPage(InputID.getText().trim()).setVisible(true);
        }
        else
        {
            JOptionPane.showMessageDialog(null, "Invalid Username and Passworde");
            InputPW.setText("");
        }
        //Sorting Array1Sort = new Sorting(Array1,choice);
    }//GEN-LAST:event_LoginButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {      
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new LoginPage().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ExitButton;
    private javax.swing.JTextField InputID;
    private javax.swing.JPasswordField InputPW;
    private javax.swing.JButton LoginButton;
    private javax.swing.JLabel Logo;
    private javax.swing.JLabel PwLabel;
    private javax.swing.JLabel UserIDLabel;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JPanel jPanel2;
    // End of variables declaration//GEN-END:variables
}
